﻿window.onbeforeunload=doOnBeforeUnload;	//onbeforeunload onunload
window.onunload=onUnLoad;
var isClose=false;
function doOnBeforeUnload()
{
	var n=window.event.screenX-window.screenLeft;      
	var b=n>document.documentElement.scrollWidth-50;      
	if(b&&window.event.clientY<0||window.event.altKey)      
	{
		isClose=true;       
		window.event.returnValue="是否确定退出该系统？";  		
	}
	else
		isClose=false;       
}
function onUnLoad()
{		
	if(isClose)  
	{
		AjaxBase.Clear(iuserid,sshowname,SessSSIP,'退出');	
	}
}
function Clear(soperate)
{			
	if (soperate=='退出')
	{
		if(!confirm("是否确定退出该系统？")) return false;
	}
	//var res=AjaxBase.Clear(iuserid,sshowname,SessSSIP,soperate);			
	//if(res.value!=null)
	{
		if (soperate=='退出')
		{
			parent.window.close();			
		}
		if (soperate=='重登')
		{			
			parent.location.href='../../Login/Login';
		}
		return true;
	}
	/*else
	{
		alert("系统操作失败");
		return false;
	}*/
}

var isShow=false;
function Refresh1_Response(text)
{    
        var content="";
        if(isShow) content="新的";
        if(text>0)
        {
            text="<div style='text-align:center;cursor:pointer' onclick=\"AddWin('../Business_Tree/funds_flow.aspx?type=funds_XG03&style=tree_max&flowtype=project_main_XG03','待办项目');MessageBox.style.visibility='hidden'\">您有"+text+"件"+content+"待办项目需要处理</div>";
            parent.fraMain.Message(text)
        }
        else
        {
            parent.fraMain.MessageHidden();
        }
        isShow=true;    	   
}
function Refresh1_Message(t)
{
    if(!parent.fraMain.MessageState) return;
    isShow=t||parent.fraMain.MessageState();
    if(isShow)
    {
        isShow=false;
        $.ajax({
            url: "?Refresh1=2",
            dataType:"text",       
            data: {                 
                t:new Date().getTime()
            },       
            success: function( text ) {
                //alert(text)
                Refresh1_Response(text)
            }
        });        
    }
}
function User_Self()
{
    parent.fraMain.AddWin('../Sys/User_Self.html','个人信息');
}
function Change_Password()
{
    parent.fraMain.AddWin('../Login/Editpsw.html','修改密码');	    
}
function ChangeTitle()
{
    parent.document.title=SystemName;
}
function Skin()
{
	parent.fraMain.AddWin('../Sys/skin.aspx?id='+iuserid,'换肤');
}
function LeftExpShrink()//展开\收缩
{	
	if(parent.Frame_Left.cols=='0,*')		
	{
	    parent.Frame_Left.cols='150,*';
	    tdLeft.style.backgroundImage="url(images/top_left.gif)";
	    document.getElementById("imgBut").src="images/top_left_buttom1.gif";	
	}
	else
	{
	    parent.Frame_Left.cols='0,*';
	    tdLeft.style.backgroundImage="url(images/top_back.gif)";
	    document.getElementById("imgBut").src="images/top_left_buttom2.gif";		
	 }
}
function Skin()
{
	parent.fraMain.AddWin('../Sys/skin.aspx?id='+iuserid,'换肤');
}